2015-09-30(腾工).sql 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainPhotographed')
  2. BEGIN
  3. DROP VIEW [dbo].BView_CameraControlBookMainPhotographed
  4. END
  5. GO
  6. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainPhotographed]'))
  7. EXEC dbo.sp_executesql @statement = N'
  8. Create VIEW [dbo].[BView_CameraControlBookMainPhotographed]
  9. AS
  10. SELECT tb_ErpOrder.ID,
  11. dbo.tb_ErpOrder.Ord_DividedShop,
  12. Ord_Type,
  13. dbo.tb_ErpOrdersPhotography.ID AS VID,
  14. dbo.tb_ErpOrder.Ord_Number,
  15. dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
  16. Ordv_DigitalNumber,
  17. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  18. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  19. Cus_Name AS 客户姓名,
  20. Cus_Sex_cs AS 客户性别,
  21. Cus_Telephone AS 客户电话,
  22. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
  23. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  24. dbo.fn_GetOrderArrears(Ord_Number) AS 欠款,
  25. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
  26. dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
  27. dbo.tb_ErpOrdersPhotography.Ordpg_Sights AS 拍摄名称,
  28. dbo.fn_CheckPhotographyStatus(Ordpg_PhotographyStatus) AS 拍摄状态,
  29. dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime) AS 摄影时间,
  30. Ordpg_ReservationPhotographyTime AS 摄影时间查询,
  31. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyName) AS 摄影师,
  32. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyAssistant) AS 摄影助理,
  33. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupArtist) AS 化妆师,
  34. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupAssistant) AS 化妆助理,
  35. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationBootDivision) AS 引导师,
  36. dbo.tb_ErpOrdersPhotography.Ordpg_Remark AS 录入备注,
  37. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_Dispatcher) AS 安排人,
  38. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_DispatchTime)) AS 安排时间,
  39. (SELECT COUNT(tb_ErpOrdersPhotography_1.Ordpg_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrdersPhotography AS tb_ErpOrdersPhotography_1 LEFT OUTER JOIN
  40. dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 ON tb_ErpOrdersPhotography_1.Ordpg_ViceNumber = tb_ErpOrderDigital_1.Ordv_ViceNumber WHERE (tb_ErpOrderDigital_1.Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
  41. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  42. dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
  43. dbo.tb_ErpOrdersPhotography ON
  44. dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber
  45. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  46. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
  47. '
  48. GO
  49. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationFilmSelectionRemind')
  50. BEGIN
  51. DROP VIEW [dbo].BView_CameraControlBookReservationFilmSelectionRemind
  52. END
  53. GO
  54. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationFilmSelectionRemind]'))
  55. EXEC dbo.sp_executesql @statement = N'
  56. CREATE VIEW [dbo].[BView_CameraControlBookReservationFilmSelectionRemind]
  57. AS
  58. SELECT
  59. dbo.tb_ErpOrder.Ord_DividedShop, Ord_Number,
  60. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  61. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  62. Cus_Name AS 客户姓名,
  63. Cus_Sex_cs AS 客户性别,
  64. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  65. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
  66. CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
  67. dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
  68. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationFilmSelectionTime)) AS 选片时间,
  69. dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime AS 选片时间查询
  70. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  71. dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
  72. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  73. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
  74. '
  75. GO
  76. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationLookDesignRemind')
  77. BEGIN
  78. DROP VIEW [dbo].BView_CameraControlBookReservationLookDesignRemind
  79. END
  80. GO
  81. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationLookDesignRemind]'))
  82. EXEC dbo.sp_executesql @statement = N'
  83. CREATE VIEW [dbo].[BView_CameraControlBookReservationLookDesignRemind]
  84. AS
  85. SELECT
  86. dbo.tb_ErpOrder.Ord_DividedShop, Ord_Number,
  87. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  88. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  89. Cus_Name AS 客户姓名,
  90. Cus_Sex_cs AS 客户性别,
  91. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  92. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
  93. CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
  94. dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
  95. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationLookDesignTime)) AS 看设计时间,
  96. dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignTime AS 看设计时间查询
  97. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  98. dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
  99. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  100. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
  101. '
  102. GO
  103. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationPhotographedRemind')
  104. BEGIN
  105. DROP VIEW [dbo].BView_CameraControlBookReservationPhotographedRemind
  106. END
  107. GO
  108. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationPhotographedRemind]'))
  109. EXEC dbo.sp_executesql @statement = N'
  110. CREATE VIEW [dbo].[BView_CameraControlBookReservationPhotographedRemind]
  111. AS
  112. SELECT
  113. dbo.tb_ErpOrder.Ord_DividedShop, Ordv_Number AS Ord_Number,
  114. dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber,
  115. CASE Ord_SinceOrderNumber WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  116. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  117. Cus_Name AS 客户姓名,
  118. Cus_Sex_cs AS 客户性别,
  119. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  120. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称
  121. ,Ordpg_Sights AS 拍摄名称
  122. ,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 拍摄时间
  123. ,dbo.fn_CheckUserIDGetUserName(Ordpg_Dispatcher) AS 安排者
  124. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  125. dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
  126. dbo.tb_ErpOrdersPhotography ON
  127. dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber
  128. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  129. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
  130. '
  131. GO
  132. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationSelectDressRemind')
  133. BEGIN
  134. DROP VIEW [dbo].BView_CameraControlBookReservationSelectDressRemind
  135. END
  136. GO
  137. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationSelectDressRemind]'))
  138. EXEC dbo.sp_executesql @statement = N'
  139. CREATE VIEW [dbo].[BView_CameraControlBookReservationSelectDressRemind]
  140. AS
  141. SELECT
  142. dbo.tb_ErpOrder.Ord_DividedShop, Ord_Number,
  143. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  144. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  145. Cus_Name AS 客户姓名,
  146. Cus_Sex_cs AS 客户性别,
  147. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  148. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
  149. CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
  150. dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_ClothingStatus) AS 选礼服状态,
  151. dbo.fn_CheckUserIDGetUserName(Ordv_ReservationClothingName) AS 选礼服负责人,
  152. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationClothingTime)) AS 选礼服时间,
  153. dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime AS 选礼服时间查询
  154. FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  155. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
  156. '
  157. GO
  158. if not exists
  159. (select * from syscolumns where id=object_id('tb_ErpOrderPhotoPrints') and name='Opps_ReworkRemark2')
  160. begin
  161. alter table tb_ErpOrderPhotoPrints add Opps_ReworkRemark2 nvarchar(500) NULL
  162. end
  163. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpOrderPhotoPrints', N'COLUMN',N'Opps_ReworkRemark2'))
  164. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'返工备注2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpOrderPhotoPrints', @level2type=N'COLUMN',@level2name=N'Opps_ReworkRemark2'
  165. GO
  166. if not exists
  167. (select * from syscolumns where id=object_id('tb_ErpOrderProductList') and name='OPlist_ReworkRemark2')
  168. begin
  169. alter table tb_ErpOrderProductList add OPlist_ReworkRemark2 nvarchar(500) NULL
  170. end
  171. IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpOrderProductList', N'COLUMN',N'OPlist_ReworkRemark2'))
  172. EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'返工备注2' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpOrderProductList', @level2type=N'COLUMN',@level2name=N'OPlist_ReworkRemark2'
  173. GO
  174. -------------------2015-09-26------------------------
  175. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationPhotographedRemind')
  176. BEGIN
  177. DROP VIEW [dbo].BView_CameraControlBookReservationPhotographedRemind
  178. END
  179. GO
  180. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationPhotographedRemind]'))
  181. EXEC dbo.sp_executesql @statement = N'
  182. CREATE VIEW [dbo].[BView_CameraControlBookReservationPhotographedRemind]
  183. AS
  184. SELECT
  185. tb_ErpOrdersPhotography.ID AS PID,
  186. dbo.tb_ErpOrder.Ord_DividedShop, Ordv_Number AS Ord_Number,
  187. dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber,
  188. CASE Ord_SinceOrderNumber WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  189. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  190. Cus_Name AS 客户姓名,
  191. Cus_Sex_cs AS 客户性别,
  192. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  193. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称
  194. ,Ordpg_Sights AS 拍摄名称
  195. ,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 拍摄时间
  196. ,dbo.fn_CheckUserIDGetUserName(Ordpg_Dispatcher) AS 安排者
  197. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  198. dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
  199. dbo.tb_ErpOrdersPhotography ON
  200. dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber
  201. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  202. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
  203. '
  204. GO
  205. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityDigitalArrangeAnPaiWorkDigital')
  206. BEGIN
  207. DROP VIEW [dbo].[BView_DoorCityDigitalArrangeAnPaiWorkDigital]
  208. END
  209. GO
  210. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityDigitalArrangeAnPaiWorkDigital]'))
  211. EXEC dbo.sp_executesql @statement = N'
  212. CREATE VIEW [dbo].[BView_DoorCityDigitalArrangeAnPaiWorkDigital]
  213. AS
  214. SELECT
  215. tb_ErpOrder.ID,
  216. Ord_Type,
  217. Ord_DividedShop,
  218. Ord_Number,
  219. Ordv_ViceNumber,
  220. Ordv_DigitalNumber,
  221. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  222. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  223. Cus_Name AS 客户姓名,
  224. Cus_Name_py AS 客户拼音,
  225. Cus_Sex_cs AS 客户性别,
  226. Cus_Telephone AS 客户电话,
  227. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairName) + ''/'' + dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修,
  228. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime)) AS 初修完成期限,
  229. dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime AS 初修完成期限查询,
  230. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerName) + ''/'' + dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计,
  231. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime)) AS 设计完成期限,
  232. dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime AS 设计完成期限查询,
  233. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementName) + ''/'' + dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修,
  234. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime)) AS 精修完成期限,
  235. dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime AS 精修完成期限查询
  236. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  237. dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
  238. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  239. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairName <> '''') OR
  240. (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2'')) AND
  241. (dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerName <> '''') OR
  242. (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2'')) AND
  243. (dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementName <> '''')
  244. '
  245. GO